package com.wdh.kjs.activity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.google.gson.Gson;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import com.wdh.kjs.R;
import com.wdh.kjs.http.Httpurl;
import com.wdh.kjs.model.JsonModel_my;
import com.wdh.kjs.util.ToastUtils;

/**
 * Created by CQH on 2016/4/21.
 */
public class RealNameAuthOrgSubActivity extends BaseTopActivity implements View.OnClickListener {
    private TextView oCompanyName;
    private TextView oUan;
    private TextView oRepresentName;
    private TextView oRepresentPhone;
    private TextView oRepresentIdNum;
    private TextView oRepresentIdNumUrl;
    private TextView oCompanyBusinessLicenseUrl;
    private TextView oBankPermitLicenseUrl;
    private String partyId;
    private JsonModel_my jsonModel_my;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.real_name_auth_org_sub);
        SharedPreferences sharedPreferences = getSharedPreferences("logininfo",MODE_PRIVATE);
        partyId = sharedPreferences.getString("loginToken", "");
        initTopBar("实名认证");
        initview();
        loadData();
    }

    private void loadData() {
        RequestParams params = new RequestParams();
       // params.addBodyParameter("partyId", "10013");
        params.addBodyParameter("partyId", partyId);

        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, Httpurl.URL_REALAUTH_ORG_INFO, params, new RequestCallBack<String>() {

            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {

                Gson gson = new Gson();
                jsonModel_my = gson.fromJson(responseInfo.result, JsonModel_my.class);

                if (jsonModel_my.success) {
                    oCompanyName.setText(jsonModel_my.getRealAuthInfo().getoCompanyName());
                    oUan.setText(jsonModel_my.getRealAuthInfo().getoUan());
                    oRepresentName.setText(jsonModel_my.getRealAuthInfo().getoRepresentName());
//                    oRepresentPhone.setText(jsonModel_my.getRealAuthInfo().getoRepresentPhone());
//                    oRepresentIdNum.setText(jsonModel_my.getRealAuthInfo().getoRepresentIdNum());
                    oRepresentIdNumUrl.setText(jsonModel_my.getRealAuthInfo().getoRepresentIdNumUrl());
                    oCompanyBusinessLicenseUrl.setText(jsonModel_my.getRealAuthInfo().getoCompanyBusinessLicenseUrl());
                    oBankPermitLicenseUrl.setText(jsonModel_my.getRealAuthInfo().getoBankPermitLicenseUrl());
                    oRepresentIdNum.setText(jsonModel_my.getRealAuthInfo().getoRepresentIdNum().substring(0, 3) + "********" + jsonModel_my.getRealAuthInfo().getoRepresentIdNum().substring(jsonModel_my.getRealAuthInfo().getoRepresentIdNum().length() - 4, jsonModel_my.getRealAuthInfo().getoRepresentIdNum().length()));
                    oRepresentPhone.setText(jsonModel_my.getRealAuthInfo().getoRepresentPhone().substring(0, 3) + "********" + jsonModel_my.getRealAuthInfo().getoRepresentPhone().substring(jsonModel_my.getRealAuthInfo().getoRepresentPhone().length() - 4, jsonModel_my.getRealAuthInfo().getoRepresentPhone().length()));
                }
            }
            @Override
            public void onFailure(HttpException error, String msg) {
                ToastUtils.showShort(getApplicationContext(), "网络异常！");
            }
        });
    }
    private void initview() {
        oCompanyName = (TextView)findViewById(R.id.oCompanyName);
        oUan = (TextView)findViewById(R.id.oUan);
        oRepresentName = (TextView)findViewById(R.id.oRepresentName);
        oRepresentPhone = (TextView)findViewById(R.id.oRepresentPhone);
        oRepresentIdNum = (TextView)findViewById(R.id.oRepresentIdNum);
        oRepresentIdNumUrl = (TextView)findViewById(R.id.oRepresentIdNumUrl);
        oCompanyBusinessLicenseUrl = (TextView)findViewById(R.id.oCompanyBusinessLicenseUrl);
        oBankPermitLicenseUrl = (TextView)findViewById(R.id.oBankPermitLicenseUrl);
    }

    public void onClick(View v) {
    }
}